home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / mkmf.prog / RCS / mkmf.man,v < prev   
Encoding:
Text File  |  1991-05-24  |  35.5 KB  |  1,017 lines

  1. head     1.11;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    ; strict;
  6. comment  @@;
  7.  
  8.  
  9. 1.11
  10. date     91.05.23.17.03.22;  author kupfer;  state Exp;
  11. branches ;
  12. next     1.10;
  13.  
  14. 1.10
  15. date     91.05.23.16.56.53;  author kupfer;  state Exp;
  16. branches ;
  17. next     1.9;
  18.  
  19. 1.9
  20. date     90.09.21.16.50.41;  author kupfer;  state Exp;
  21. branches ;
  22. next     1.8;
  23.  
  24. 1.8
  25. date     90.02.27.17.46.06;  author douglis;  state Exp;
  26. branches ;
  27. next     1.7;
  28.  
  29. 1.7
  30. date     89.05.22.12.30.14;  author jhh;  state Exp;
  31. branches ;
  32. next     1.6;
  33.  
  34. 1.6
  35. date     89.04.03.22.19.32;  author douglis;  state Exp;
  36. branches ;
  37. next     1.5;
  38.  
  39. 1.5
  40. date     89.04.03.22.17.47;  author douglis;  state Exp;
  41. branches ;
  42. next     1.4;
  43.  
  44. 1.4
  45. date     89.04.03.22.16.36;  author douglis;  state Exp;
  46. branches ;
  47. next     1.3;
  48.  
  49. 1.3
  50. date     88.12.30.09.56.12;  author ouster;  state Exp;
  51. branches ;
  52. next     1.2;
  53.  
  54. 1.2
  55. date     88.12.28.12.05.25;  author ouster;  state Exp;
  56. branches ;
  57. next     1.1;
  58.  
  59. 1.1
  60. date     88.12.28.11.43.58;  author ouster;  state Exp;
  61. branches ;
  62. next     ;
  63.  
  64.  
  65. desc
  66. @@
  67.  
  68.  
  69. 1.11
  70. log
  71. @Add a couple .LP's to separate main text from examples.
  72. @
  73. text
  74. @' $Header: /sprite/src/cmds/mkmf.prog/RCS/mkmf.man,v 1.10 91/05/23 16:56:53 kupfer Exp Locker: kupfer $ SPRITE (Berkeley)
  75. .so \*(]ltmac.sprite
  76. .HS MKMF cmds
  77. .BS
  78. .SH NAME
  79. mkmf \- generate Makefiles automatically
  80. .SH SYNOPSIS
  81. \fBmkmf\fR [\fB\-f \fImakefile\fR] [\fB\-x\fR] [\fB\-m \fImachineType\fR]
  82. [\fB-m\fImachineType\fR]
  83. .SH OPTIONS
  84. .IP "\fB\-f \fImakefile\fR"
  85. Generate a file named \fImakefile\fR
  86. instead of \fBMakefile\fR.  Also use \fImakefile.\fBproto\fR,
  87. \fImakefile.\fBed\fR, and \fImakefile\fR.\fBex\fR instead of
  88. \fBMakefile.proto\fR etc.
  89. .IP "\fB\-x\fR"
  90. Turns on echo-ing so that all the commands in the \fBmkmf\fR scripts
  91. are printed on the terminal.  This is useful primarily for
  92. debugging \fBmkmf\fR scripts.
  93. .IP "\fB\-m \fImachineType\fR or \fB-m\fImachineType\fR"
  94. Work only on subdirectory for
  95. \fImachineType\fR. Multiple \fB\-m\fR flags
  96. can be used to run \fBmkmf\fR on multiple machine types.
  97. .BE
  98.  
  99. .SH INTRODUCTION
  100. .LP
  101. \fBMkmf\fR generates a \fBMakefile\fR for the current working directory.  It
  102. also creates additional make-related files in machine-dependent
  103. subdirectories of the current directory.  \fBMkmf\fR can generate
  104. \fBMakefile\fRs for a variety of directories, including those holding programs,
  105. libraries, header libraries, kernel sources, and other things.
  106. \fBmkmf\fR manages all of the directories holding Sprite system code.
  107. In normal use, all you should have to do is type "mkmf";  \fBmkmf\fR
  108. will generate a suitable \fBMakefile\fR based on the directory's full
  109. path name and
  110. the files and subdirectories in it.  After that you can invoke
  111. \fBpmake\fR to recompile in the directory, install, and so on.  The files
  112. produced by \fBmkmf\fR will only work with \fBpmake\fR, not with the original
  113. UNIX version of \fBmake\fR (but in Sprite \fBmake\fR is a symbolic link to
  114. \fBpmake\fR).  This man page assumes that you are familiar with \fBpmake\fR;  if
  115. not, you should read the \fBpmake\fR tutorial.
  116. .LP
  117. Warning:  there is also a UNIX program called \fBmkmf\fR;  although its
  118. general goal is the same as this program's, its mechanisms are very different.
  119. .LP
  120. Normally, you should re-run \fBmkmf\fR in a directory whenever you add or delete
  121. source files.  When \fBmkmf\fR runs, it assumes that
  122. all of the source files (those with extensions .c, .h, .y, etc.)
  123. are to be used to create a single program or library, and it
  124. generates \fBMakefile\fR accordingly.  If there are source files that
  125. don't pertain to the thing being created (e.g. test programs),
  126. put them in a subdirectory where \fBmkmf\fR won't see them.
  127.  
  128. .SH "MAKEFILE STRUCTURE"
  129. .LP
  130. The makefile structure that \fBmkmf\fR generates is a bit complicated,
  131. but it's also powerful and flexible.  Among other things, it supports
  132. compilation for multiple target machines from a single set of source
  133. files, and it makes it easy to make a global change in the way all
  134. directories of a particular type are made (e.g. all command programs, or all
  135. libraries).  For most directories
  136. there are five kinds of \fBpmake\fR-related files:
  137. .IP "\fBMakefile\fP"
  138. This is the main file generated by \fBmkmf\fR, but it is short and
  139. does relatively little.  It sets up several \fBpmake\fR
  140. variables that give the name of the program, a list of target machines
  141. for which the program can be compiled, default flags for C compilation,
  142. and so on.  Then \fBMakefile\fR includes the other files described below,
  143. which contain most of the useful \fBpmake\fR-related information.
  144. \fBMakefile\fR contains information that may be different for this
  145. directory than for other directories of the same type (for example, each
  146. library has a different
  147. name), but it only contains information that is independent of the particular
  148. target machine being compiled for.
  149. .IP "\fB*.md/md.mk\fP"
  150. There is one subdirectory for each target machine that this program
  151. or library or module can be compiled to run on.  These are called
  152. \fImachine-dependent subdirectories\fR and have names \fIx\fB.md where
  153. \fIx\fR is the type of the target machine, e.g., \fBsun2.md\fR
  154. or \fBsun3.md\fR.  A machine-dependent subdirectory holds all
  155. information that is different for that particular machine than for
  156. other machines.  This includes the object files compiled for that
  157. machine, plus any machine-dependent sources.  Most user programs don't have
  158. machine-dependent sources, but many of the kernel modules and
  159. libraries do.  In each machine-dependent subdirectory there is a
  160. file \fBmd.mk\fR, generated automatically by \fBmkmf\fR.
  161. \fBMd.mk\fR is included by \fBMakefile\fR and
  162. creates variables like \fBSRCS, OBJS\fR, and \fBHDRS\fR.  These describe
  163. the files needed
  164. to recompile for that target machine, including both the machine-independent
  165. files in the parent directory (the one containing \fBMakefile\fR) and
  166. the machine-dependent files in the \fIx\fB.md\fR subdirectory.
  167. .IP "\fB*.md/dependencies.mk\fP"
  168. There is one of these files in each machine-dependent subdirectory.
  169. \fBDependencies.mk\fR lists the header files used directly or
  170. indirectly by each source file.  It is included by \fBMakefile\fR so that
  171. \fBpmake\fR will do the appropriate recompilations when headers change.
  172. \fBDependencies.mk\fR files are generated automatically by \fBmakedepend\fR.
  173. The command ``pmake depend'' will run \fBmakedepend\fR
  174. to regenerate \fBdependencies.mk\fR.  \fBMkmf\fR also issues
  175. a ``pmake depend'' command whenever it runs.
  176. .IP "\fIsysmakefile\fR"
  177. There only a few different kinds of source directories in Sprite:
  178. commands, libraries, kernel modules, etc (see ``HOW MKMF WORKS''
  179. below).  For each of these types
  180. of directories, there is one file of \fBpmake\fR commands that contains
  181. all of the ``real stuff'' that controls recompilation, installing,
  182. etc.  \fBMakefile\fR sets the variable \fBSYSMAKEFILE\fR to hold the name
  183. of this file, and under normal conditions \fBMakefile\fR will
  184. include the sysmakefile whenever \fBpmake\fR is invoked (see
  185. ``PERSONALIZATION'' below for exceptions to this rule).
  186. The sysmakefiles use the variables and dependencies set up by \fBMakefile\fR,
  187. \fBmd.mk\fR, and \fBdependencies.mk\fR.
  188. The sysmakefiles are all stored in \fB/sprite/lib/pmake\fR.
  189. .IP "\fIutility makefiles\fR"
  190. There is a collection of small makefiles in the directory
  191. \fB/sprite/lib/pmake\fR, which are include by sysmakefiles for
  192. operations that are shared by many sysmakefiles.
  193.  
  194. .SH "STANDARD TARGETS"
  195. .LP
  196. Several standard \fBpmake\fR targets are available in any directory managed
  197. by \fBmkmf\fR:
  198. .TP 14
  199. \fIdefault\fR
  200. If you type \fBpmake\fR with no arguments, then the default target
  201. just recompiles the program or library in this directory.  Compiled
  202. files are placed in the .\fBmd\fR subdirectory for the current target machine
  203. (see below for more information on target machines).
  204. .TP 14
  205. \fBclean\fR
  206. Remove any files that can be regenerated automatically by \fBpmake\fR.
  207. This frees up space on disk and forces a complete recompilation the
  208. next time \fBpmake\fR is invoked.
  209. .TP 14
  210. \fBtidy\fR
  211. Remove any files that can be regenerated automatically by \fBpmake\fR,
  212. except the executable produced for a command.
  213. This frees up space on disk and forces a complete recompilation the
  214. next time \fBpmake\fR is invoked, but it leaves around the unstripped 
  215. executable for debugging purposes.
  216. .TP 14
  217. \fBdebug\fR
  218. Valid for libraries only.  Generate a version of the library with
  219. debugging symbols.  The default for libraries is to compile without
  220. debugging information
  221. .TP 14
  222. \fBdepend\fR
  223. Regenerate the \fBdependencies.mk\fR file in the \fB.md\fR subdirectory for
  224. the current target machine.  This target should be re-made when source
  225. files are created or deleted, or when header file usage has changed.
  226. .TP 14
  227. \fBinstall\fR
  228. Recompiles the information in this directory and installs it in its
  229. official system location, so that it can be used by other people.
  230. For commands, this means copying the binary of the command to the
  231. appropriate system command directory and saving the old installed
  232. version of the command in a backup directory.  For libraries, it means
  233. copying the library's .\fBa\fR file to the relevant library directory,
  234. and also installing the library's header files and lint library.
  235. .TP 14
  236. \fBinstalldebug\fR
  237. Valid for libraries only.  Install the version of the library with
  238. debugging symbols.
  239. .TP 14
  240. \fBinstallhdrs\fR
  241. This target is only available in library and header directories.  It
  242. installs the public header files for the module in the appropriate system
  243. header directory.  \fBMkmf\fR decides
  244. which header files are public and which are private based on the files'
  245. names.  In order to be public, the first letters of a \fB.h\fR file
  246. must be the same as the name of the directory, and the string \fBInt\fR
  247. must not appear in the file's name.  Thus, in the library \fBsx\fR
  248. the file \fBsx.h\fR is public, whereas the files \fBsxInt.h\fR and
  249. \fBfoo.h\fR are treated as private.
  250. .TP 14
  251. \fBinstalllint\fR
  252. This target is only available in library directories.  It generates
  253. a lint library file for the contents of this module and installs it
  254. in the system lint library.
  255. .TP 14
  256. \fBinstallprofile\fR
  257. This target is only available in library directories.  It installs
  258. the version of the library that has been compiled for profiling.
  259. .TP 14
  260. \fBlint\fR
  261. Run lint on this program/library and the other programs and libraries
  262. it uses.  Output is placed in the file \fBlint\fR in the \fB.md\fR subdirectory
  263. for the current machine.
  264. .TP 14
  265. \fBmkmf\fR
  266. Run \fBmkmf\fR to regenerate the Makefile for this directory.   This target is
  267. particularly useful in top-level directories with many children,
  268. since it will run \fBmkmf\fR recursively in
  269. each of the subdirectories.
  270. .TP 14
  271. \fBnewtm\fR
  272. Set things up to compile for a new type of target machine (which
  273. must be specified
  274. explicitly using the \fBTM\fR variable).  This includes creating a \fB.TM\fR
  275. subdirectory and re-running \fBmkmf\fR.
  276. .TP 14
  277. \fBprofile\fR
  278. Compile a profiled version of the command or library.
  279. .TP 14
  280. \fBtags\fR
  281. Generate a \fBtags\fR file in this directory that describes all the
  282. information in all of the source files for this program or library,
  283. including both the machine-independent sources and the machine-dependent
  284. sources for all target machines.
  285.  
  286. .SH "TARGET MACHINES"
  287. .LP
  288. The above targets all apply to the ``current target machine'', which
  289. is the value of the \fBTM\fR variable in \fBMakefile\fR.  If you wish to
  290. compile for a different target machine, you can specify an explicit
  291. value of the \fBTM\fR variable on the \fBpmake\fR command line, such as
  292. .IP
  293. \fBpmake\ \ TM=sun2\fR
  294. .LP
  295. or
  296. .IP
  297. \fBpmake\ \ install\ \ TM=sun3\fR
  298. .LP
  299. There are also four other ways you can specify target machines
  300. as part of \fBpmake\fR targets:
  301. .TP 14
  302. \fItm\fR
  303. If you specify a target machine as a \fBpmake\fR target, such as
  304. \fBpmake sun2\fR, then the default target will be made for that
  305. particular machine
  306. .TP 14
  307. \fBall\fR
  308. The \fBall\fR target causes the default target to be made for all
  309. target machines currently known for this directory.
  310. .TP 14
  311. \fItarget tm\fR
  312. If you add a machine name as a suffix to one of the standard targets,
  313. e.g., \fBpmake installsun2\fR or \fBpmake lintsun3\fR, the result
  314. is equivalent to specifying the \fBTM\fR variable:  the target is
  315. re-made for the given machine instead of the default machine.
  316. .TP 14
  317. \fItarget\fBall\fR
  318. If you add the \fBall\fR suffix to a target, e.g. \fBpmake installall\fR,
  319. then \fItarget\fR will be re-made for all known target machines.
  320. .LP
  321. The list of known target machines is given by the \fBMACHINES\fR
  322. variable specified in \fBMakefile\fR.  This variable is set from the names
  323. of \fB.md\fR subdirectories at the time \fBmkmf\fR is run.  To add a new target
  324. machine, \fBfoo\fR for example, create a subdirectory \fBfoo.md\fR
  325. and then re-run \fBmkmf\fR.
  326.  
  327. .SH "ADDITIONAL PMAKE VARIABLES"
  328. .LP
  329. There are a few variable names that \fBmkmf\fR reserves exclusively
  330. for your use, as a way of controlling various things.  The makefiles
  331. generated by \fBmkmf\fR will use these variables, if you set them on a
  332. \fBpmake\fR command line:
  333. .TP 14
  334. \fBNOBACKUP\fR
  335. Normally, when a command is installed the previous version of the
  336. command is saved in a backup directory.  If you set the \fBNOBACKUP\fR
  337. variable to any value, then no backup copy will be saved.  
  338. .TP 14
  339. \fBBACKUPAGE\fR
  340. If NOBACKUP is not defined, then normally, a backup overwrites a
  341. previous backup only if the file being backed up is sufficiently old
  342. to be deemed stable (run \fBupdate -help\fR for information about the
  343. default age).  BACKUPAGE, if set, overrides the default age used for
  344. this purpose.
  345. .TP 14
  346. \fBXAFLAGS\fR
  347. Extra flags that will be used in all assembler invocations, in addition
  348. to the standard ones set up by the makefiles.
  349. .TP 14
  350. \fBXCFLAGS\fR
  351. Extra flags that will be used in all C compilations, in addition
  352. to the standard ones set up by the makefiles.
  353. .LP
  354. In addition to the variables above, you can also override other variables
  355. defined in the makefiles.  See "LOCAL.MK VARIABLES" below.
  356.  
  357. .SH "PERSONALIZATION"
  358. .LP
  359. The makefiles generated by \fBmkmf\fR won't always do the right thing
  360. without additional program-specific information.
  361. For example, a particular program may need to
  362. use additional libraries besides the C library, or it may need
  363. particular compiler switches, or certain files may need special
  364. processing during compilation.  There are six ways to personalize
  365. the information in a particular directory, each of which is
  366. invoked by creating a file with a particular name:
  367. .TP 14
  368. \fBkernel.mk\fR
  369. This file can be used to create personalized Sprite kernels.
  370. \fBMakefile\fRs in kernel module directories will check for the 
  371. existence of a \fBkernel.mk\fR file in your home directory. 
  372. If the file exists it will be included prior to including any other
  373. files. 
  374. The \fBkernel.mk\fR is intended modify the behavior of a sysmakefile
  375. for
  376. a kernel module, 
  377. not to replace it. 
  378. In this respect a \fBkernel.mk\fR file is different from a \fBlocal.mk\fR file.
  379. .TP 14
  380. \fBlocal.mk\fR
  381. This is the simplest and most common form of personalization.
  382. \fBMakefile\fR checks for the existence of \fBlocal.mk\fR;  if it
  383. exists, then \fBMakefile\fR includes it instead of the sysmakefile.
  384. Usually \fBlocal.mk\fR contains a few \fBpmake\fR commands, then it
  385. includes the sysmakefile (whose name is passed in the variable
  386. SYSMAKEFILE), then it issues a few more \fBpmake\fR
  387. commands.  See "LOCAL.MK EXAMPLES" below.
  388. .TP 14
  389. \fBMakefile.sed\fR
  390. If \fBMakefile.sed\fR exists when \fBmkmf\fR runs, then \fBmkmf\fR uses it as a Sed
  391. script to modify \fBMakefile\fR.  If the \fB\-f\fR switch has been used
  392. to specify a different makefile, say \fBfoo\fR, then \fBmkmf\fR looks for
  393. \fBfoo.sed\fR.  In particular, you can place a file \fBmd.mk.sed\fR
  394. in a machine-dependent subdirectory in order to modify the \fBmd.mk\fR
  395. file.  Most things that you can do with a
  396. \fBMakefile.sed\fR script you can also do in a \fBlocal.mk\fR file;
  397. this feature is mostly a leftover from ancient times when the
  398. \fBlocal.mk\fR facility didn't exist.
  399. .TP 14
  400. \fBMakefile.ex\fR
  401. Similar to \fBMakefile.sed\fR, except \fBmkmf\fR uses it as an Ex script to
  402. modify \fBMakefile\fR.
  403. .TP 14
  404. \fBMakefile.proto\fR
  405. If this file exists when \fBmkmf\fR runs, then \fBmkmf\fR uses it as a
  406. prototype makefile instead
  407. of one from the \fBmkmf\fR library.  See ``HOW MKMF WORKS''
  408. below for what this means.
  409. .TP 14
  410. \fBmkmf.local\fR
  411. If this file exists, it must be a shell script.  It will be executed
  412. by \fBmkmf\fR in place of the standard type-specific \fBmkmf\fR script that would
  413. normally be executed to generate \fBMakefile\fR.  See ``HOW MKMF WORKS''
  414. below for more information on this.
  415. .LP
  416. Finally, there is one other, even more radical,
  417. way for you to control what's in your \fBMakefile\fR,
  418. and that is to create your own \fBMakefile\fR from scratch
  419. and make sure it
  420. contains a line ``# No mkmf''.  \fBMkmf\fR will refuse to do anything
  421. if it finds a \fBMakefile\fR with such a comment in it;
  422. you can then put anything you like in the \fBMakefile\fR.
  423. It's probably a bad idea (and unnecessary) for you ever to generate
  424. a Makefile by hand in any Sprite system
  425. directory, but if you do, be sure it has a ``# No mkmf'' line:
  426. it is common practice to run \fBmkmf\fR indiscriminately on system directories,
  427. and this will make sure your \fBMakefile\fR doesn't accidentally
  428. get overwritten (actually, \fBmkmf\fR won't overwrite a makefile unless
  429. it finds a line ``# Allow mkmf'' in it, but if it doesn't find a
  430. ``# No mkmf'' line then it will ask for permission to overwrite it).
  431.  
  432. .SH "HOW MKMF WORKS"
  433. .LP
  434. The \fBmkmf\fR program runs as a two-stage shell script.  The top-level
  435. script is the \fBmkmf\fR program itself.  It does things that are
  436. common to all uses of \fBmkmf\fR, such as checking for the ``# Allow mkmf''
  437. line in your \fBMakefile\fR and running \fBpmake dependall\fR.
  438. There are several second-level shell scripts, called \fItype-specific\fR
  439. scripts.  Each one of these scripts is set up to handle a particular
  440. kind of directory, such as those for libraries, programs, or directories
  441. containing only header files.
  442. The type-specific scripts correspond to the sysmakefiles:  for
  443. each type, there is an \fBmkmf\fR script to generate its \fBMakefile\fR, a
  444. prototype makefile that the script fills in, and a sysmakefile in
  445. \fB/sprite/lib/pmake\fR that does most of the real work for making
  446. things of that type.
  447. The type-specific scripts and prototype makefiles are all
  448. stored in \fB/sprite/lib/mkmf\fR with names like \fBmkmf.library\fR
  449. and \fBMakefile.library\fR.
  450. .LP
  451. \fBMkmf\fR uses the file \fB/sprite/lib/mkmf/mkmf.map\fR to select
  452. which type-specific script to use.  \fBMkmf.map\fR is an awk script
  453. that performs pattern matching on the current directory to select
  454. a type-specific script.  This file has already been set up to handle
  455. most of the system areas, but if you add a major new area of programs
  456. or libraries you'll probably have to add a new entry in \fBmkmf.map\fR.
  457. If \fBmkmf\fR finds a script \fBmkmf.local\fR in the current directory, then
  458. \fBmkmf\fR uses it instead of the one that would have been selected by
  459. \fBmkmf.map\fR.  Similarly, if there is a file \fBMakefile.proto\fR
  460. in the current directory, it is used instead of the default prototype
  461. makefile.
  462. .LP
  463. You can reconfigure the way that \fBmkmf\fR works by placing a file \fB.mkmf\fR
  464. in your home directory.  If this file exists, \fBmkmf\fR will source it as a
  465. shell script just after doing its initialization.  You can use this
  466. feature to set up a private map for yourself and change other internal
  467. features of \fBmkmf\fR.  For more details on how this works, read the top-level
  468. \fBmkmf\fR script.
  469.  
  470. .SH "CURRENT TYPES"
  471. .LP
  472. Although the list of available type-dependent scripts will probably
  473. grow and change faster than this man page can be updated, here are the
  474. types that were available as of the last time the man page was
  475. updated.  To force \fBmkmf\fR to use a particular type (e.g.,
  476. ``library'' instead of ``command''), use either a \fBmkmf.local\fR or
  477. a \fBMakefile.proto\fR, as described in ``HOW MKMF WORKS,'' above.
  478. .TP 14
  479. \fBcommand\fR
  480. This type is for command directories where all of the files related
  481. to the command are together in a single directory and its \fB.md\fR
  482. subdirectories.  It is the default type used by \fBmkmf\fR for directories
  483. not explicitly listed in \fBmkmf.map\fR.
  484. \fBMakefile\fR will compile and link the command into
  485. \fItm\fB.md/\fIname\fR, where \fItm\fR is the name of a target machine
  486. and \fIname\fR is the name of the directory containing \fBMakefile\fR
  487. (the directory name and command name are assumed to be the same).
  488. \fBMakefile\fR will install the command into the appropriate system
  489. directory (see the \fBmkmf\fR scripts for details on where this is).
  490. During the conversion of Sprite to the new C library, this type of
  491. directory is actually \fBcommand2\fR, but it will revert to \fBcommand\fR
  492. when the conversion is finished.
  493. .TP 14
  494. \fBbigcmd\fR
  495. This type is for commands whose source files have been partitioned into
  496. multiple subdirectories, with one \fBMakefile\fR for each subdirectory.
  497. The \fBMakefile\fRs in the subdirectories are of type \fBbigcmd\fR,
  498. and the \fBMakefile\fR of the parent is of type \fBbigcmdtop\fR.
  499. Each \fBbigcmd\fR subdirectory contains \fItm\fB.md\fR subdirectories,
  500. which contain object files compiled from that subdirectory plus a file
  501. \fBlinked.o\fR, which consists of all the object files from that
  502. subdirectory linked together.
  503. .TP 14
  504. \fBbigcmdtop\fR
  505. This type is used for a command source directory that contains one
  506. or more subdirectories of type \fBbigcmd\fR.  The \fBMakefile\fR in this
  507. directory will cause all the children directories to be re-made,
  508. plus it will regenerate the file \fItm\fB.md/\fIname\fR, where \fItm\fR
  509. is the name of a target machine and \fIname\fR is the name of the
  510. \fBbigcmdtop\fR directory.  A special target \fBquick\fR is also available
  511. in \fBbigcmdtop\fR directories:  it will relink \fItm\fB.md/\fIname\fR
  512. using the existing \fBlinked.o\fR files from the children, without
  513. passing through all the subdirectories to remake there.
  514. .TP 14
  515. \fBlibrary\fR
  516. This type is for directories containing all of the files related to
  517. a particular library.  \fBMakefile\fR will compile all the files in
  518. the directory and assemble them into an archive file named
  519. \fItm\fB.md/lib\fIname\fB.a, where \fItm\fR is the name of a target machine
  520. and \fIname\fR is the name of the directory containing \fBMakefile\fR
  521. (the directory name and library name are assumed to be the same).
  522. \fBMakefile\fR will install the library and its headers and lint library.
  523. .TP 14
  524. \fBbiglib\fR
  525. This type is for libraries with many source files, such as the C
  526. library.  The library's sources are assumed to be split over many
  527. subdirectories, with one \fBMakefile\fR for each subdirectory.  The
  528. \fBMakefile\fRs in the subdirectories are of type \fBbiglib\fR, and
  529. the \fBMakefile\fR of the parent is of type \fBbiglibtop\fR.  Compiled
  530. files will be archived together into the
  531. file \fB../\fItm\fB.md/lib\fIname\fB.a\fR (relative to the subdirectories
  532. containing the \fBbiglib\fR \fBMakefile\fRs), where \fItm\fR is the name
  533. of a target machine and \fIname\fR is the name of the top-level
  534. directory (the directory containing the \fBbiglib\fR directories is
  535. assumed to have the same name as the overall library).
  536. .TP 14
  537. \fBbigligtop\fR
  538. This is the type of a directory that contains one or more \fBbiglib\fR
  539. subdirectories.  The \fBMakefile\fR in this directory will pass most
  540. of the standard targets along to its children directories.  The
  541. installation targets (such as \fBinstall\fR and \fBinstalllint\fR)
  542. should be invoked in this directory.  A special target \fBinstallquick\fR
  543. is also available in \fBbiglibtop\fR directories:  it will install
  544. the standard version of the library without cycling through all of
  545. the subdirectories to give each of them a chance to recompile.
  546. .TP 14
  547. \fBkernel\fR
  548. This type is used in the directories that hold the major modules of
  549. the Sprite kernel.
  550. .TP 14
  551. \fBhdrs\fR
  552. This type is used for directories that hold nothing but ``.h'' files
  553. for the standard library.  The only thing you can do with \fBpmake\fR is to
  554. install the header files;  the default target does this, as does
  555. \fBpmake install\fR.  In addition, \fBpmake recursive\fR will install
  556. header files in this directory and all of its subdirectories (this is
  557. only useful for header directories that contain more header directories
  558. as subdirectories).
  559. .TP 14
  560. \fBtop\fR
  561. This is a general-purpose type for directories that don't
  562. have anything interesting in themselves, but have child directories
  563. that do contain interesting things.  When \fBpmake\fR is run in such
  564. a directory, the \fBMakefile\fR will simply pass all the standard targets
  565. down to each of its child directories in turn.  This type of \fBMakefile\fR
  566. is used, for example, in the top-level directory of a \fBbiglib\fR
  567. tree, or in a top-level commands directory, each of whose children
  568. is of type \fBcommand\fR.
  569.  
  570. .SH "LOCAL.MK VARIABLES"
  571. .PP
  572. The following list describes some of the variables that you may wish
  573. to use, augment (using ``+=''), or override in \fBlocal.mk\fR files.
  574. This is just a list of the most commonly-used variables.  For other
  575. possibilities, read the makefiles.
  576. .TP 18
  577. \fBAFLAGS\fR
  578. Flags passed to the assembler.  You may wish to augment this in \fBlocal.mk\fR.
  579. .TP 18
  580. \fBCFLAGS\fR
  581. Flags passed to the C compiler.  You may wish to augment this in
  582. \fBlocal.mk\fR, for example to define certain compiler switches.
  583. Or, you can override the value in \fBMakefile\fR with something
  584. completely different.
  585. .TP 18
  586. \fBCLEANOBJS\fR
  587. A list of object files and other things to delete as part of
  588. \fBpmake clean\fR or \fBpmake tidy\fR.
  589. .TP 18
  590. \fBHDRS\fR
  591. A list of all the locally-defined ``.h'' files (both machine-dependent
  592. and machine-independent) used to compile this module.
  593. .TP 18
  594. \fBINSTALLDIR\fR
  595. The base directory in which a program gets installed.  \fBMkmf\fR will add
  596. a machine-dependent suffix onto this, depending on the particular
  597. machine being compiled for (see the makefiles for more details on this).
  598. .TP 18
  599. \fBINSTALLFLAGS\fR
  600. Flags passed to \fBupdate\fR when the module is installed.  You may wish
  601. to add extra flags, like \fB\-m 4755\fR to make a program set-user-id.
  602. .TP 18
  603. \fBOBJS\fR
  604. A list of all the object files used to link together this module.
  605. These files should always be in a machine-dependent directory.
  606. .TP 18
  607. \fBSRCS\fR
  608. A list of all the source files (both machine-dependent and
  609. machine-independent) that comprise the module's version for the
  610. current target machine.
  611. .TP 18
  612. \fBSUBDIRS\fR
  613. A list of all the subdirectories of this directory, except those of
  614. type \fItm\fB.md\fR).  Is usually only
  615. available in top-level Makefiles, like those in directories of type
  616. \fBtop\fR, \fBbigcmdtop\fR, or \fBbiglibtop\fR.  This variable determines
  617. where to invoke recursive sub-makes.
  618. .TP 18
  619. \fBTM\fR
  620. The name of the current target machine.  Normally this is specified on
  621. the command line or defaulted in \fBMakefile\fR, so you shouldn't
  622. modify it.
  623.  
  624. .SH "LOCAL.MK EXAMPLES"
  625. .PP
  626. The normal structure for a \fBlocal.mk\fR file is for it to set
  627. up or modify a few variables, include the sysmakefile, and then
  628. add new targets or extend targets defined by the sysmakefile.
  629. For example, here is a simple \fBlocal.mk\fR that defines some
  630. additional compiler variables (by adding to \fBCFLAGS\fR) and
  631. uses an extra library:
  632. .DS
  633. \fBCFLAGS    += -DNAME=testProg
  634. LIBS        += -lm\ \ -X11
  635. #include    <$(SYSMAKEFILE)>\fR
  636. .DE
  637. .LP
  638. Or, below is a \fBlocal.mk\fR that generates an additional C file from
  639. a template.  Since the file may not have existed when \fBmkmf\fR was run, it
  640. must be added to the \fBSRCS\fR and \fBOBJS\fR variables generated by
  641. \fBmkmf\fR.  In addition, when this program is installed (using the \fBupdate\fR
  642. command), it is marked at set-user-id (mode 4755):
  643. .DS
  644. \fBSRCS            += auto.c
  645. OBJS            += $(TM).md/auto.o
  646. INSTALLFLAGS    += -m 4755
  647.  
  648. #include        <$(SYSMAKEFILE)>
  649.  
  650. auto.c: template prog
  651.     prog template > auto.c\fR
  652. .DE
  653. .LP
  654. The reason for adding new targets after including the sysmakefile
  655. is to allow the sysmakefile to define the first target, which is the
  656. default that will be made if \fBpmake\fR is invoked with no arguments.  If,
  657. on the other hand, you want to change the default target, then you
  658. can define the default target before including the sysmakefile.
  659. .LP
  660. As a third example, consider a program that uses non-standard header
  661. files.  It would have a local.mk that looks something like
  662. .DS
  663. \fB#include    <$(SYSMAKEFILE)>
  664.  
  665. \&.PATH.h :    /sprite/lib/include.special
  666. .DE
  667. .LP
  668. Notice that the 
  669. .B .PATH.h
  670. line comes after the sysmakefile is included.
  671.  
  672. .SH "SEE ALSO"
  673. pmake, sed, ex
  674.  
  675. .SH KEYWORDS
  676. make, Makefile, prototype
  677. @
  678.  
  679.  
  680. 1.10
  681. log
  682. @Add a local.mk example for using .PATH.h.
  683. @
  684. text
  685. @d1 1
  686. a1 1
  687. ' $Header: /sprite/src/cmds/mkmf.prog/RCS/mkmf.man,v 1.9 90/09/21 16:50:41 kupfer Exp Locker: kupfer $ SPRITE (Berkeley)
  688. d564 1
  689. d594 1
  690. @
  691.  
  692.  
  693. 1.9
  694. log
  695. @Add a note to the CURRENT TYPES section about how to force mkmf to use
  696. a particular type.
  697. @
  698. text
  699. @d1 1
  700. a1 1
  701. ' $Header: /sprite/src/cmds/mkmf.prog/RCS/mkmf.man,v 1.8 90/02/27 17:46:06 douglis Exp Locker: kupfer $ SPRITE (Berkeley)
  702. d585 11
  703. @
  704.  
  705.  
  706. 1.8
  707. log
  708. @documented BACKUPAGE
  709. @
  710. text
  711. @d1 1
  712. a1 1
  713. ' $Header: /sprite/src/cmds/mkmf.prog/RCS/mkmf.man,v 1.7 89/05/22 12:30:14 jhh Exp Locker: douglis $ SPRITE (Berkeley)
  714. d400 5
  715. a404 3
  716. grow and change faster than this man page can be updated, here are
  717. the types that were available as of the last time the man page was
  718. updated:
  719. @
  720.  
  721.  
  722. 1.7
  723. log
  724. @can now do -mtm
  725. @
  726. text
  727. @d1 1
  728. a1 1
  729. ' $Header: /a/newcmds/mkmf.prog/RCS/mkmf.man,v 1.6 89/04/03 22:19:32 douglis Exp $ SPRITE (Berkeley)
  730. d264 8
  731. a271 1
  732. variable to any value, then no backup copy will be saved.
  733. @
  734.  
  735.  
  736. 1.6
  737. log
  738. @added tidy in the right place, under "standard targets"
  739. @
  740. text
  741. @d1 1
  742. a1 1
  743. ' $Header: /a/newcmds/mkmf.prog/RCS/mkmf.man,v 1.4 89/04/03 22:16:36 douglis Exp Locker: douglis $ SPRITE (Berkeley)
  744. d9 1
  745. d20 1
  746. a20 1
  747. .IP "\fB\-m \fImachineType\fR"
  748. @
  749.  
  750.  
  751. 1.5
  752. log
  753. @mention "tidy" along with "clean".
  754. @
  755. text
  756. @d136 7
  757. @
  758.  
  759.  
  760. 1.4
  761. log
  762. @JHH added the kernel.mk personalization.
  763. @
  764. text
  765. @d1 1
  766. a1 1
  767. ' $Header: /a/newcmds/mkmf.prog/RCS/mkmf.man,v 1.3 88/12/30 09:56:12 ouster Exp $ SPRITE (Berkeley)
  768. d498 1
  769. a498 1
  770. \fBpmake clean\fR.
  771. @
  772.  
  773.  
  774. 1.3
  775. log
  776. @More format upgrades.
  777. @
  778. text
  779. @d1 1
  780. a1 1
  781. ' $Header: /a/newcmds/mkmf.prog/RCS/mkmf.man,v 1.2 88/12/28 12:05:25 ouster Exp Locker: ouster $ SPRITE (Berkeley)
  782. d8 1
  783. a8 1
  784. \fBmkmf\fR [\fB\-f \fImakefile\fR] [\fB\-x\fR]
  785. d19 4
  786. d276 1
  787. a276 1
  788. processing during compilation.  There are five ways to personalize
  789. d279 12
  790. @
  791.  
  792.  
  793. 1.2
  794. log
  795. @Upgrade to new official man page format.
  796. @
  797. text
  798. @d1 1
  799. a1 1
  800. ' $Header: /a/newcmds/mkmf.prog/RCS/mkmf.man,v 1.1 88/12/28 11:43:58 ouster Exp Locker: ouster $ SPRITE (Berkeley)
  801. d8 1
  802. a8 1
  803. \fBmkmf\fR [\fB-f \fImakefile\fR] [\fB-x\fR]
  804. d10 1
  805. a10 1
  806. .IP "\fB-f \fImakefile\fR"
  807. d15 2
  808. a16 2
  809. .IP "\fB-x\fR"
  810. Turns on echo-ing so that all the commands in the Mkmf scripts
  811. d18 1
  812. a18 1
  813. debugging Mkmf scripts.
  814. d23 1
  815. a23 1
  816. Mkmf generates a \fBMakefile\fR for the current working directory.  It
  817. d25 1
  818. a25 1
  819. subdirectories of the current directory.  Mkmf can generate
  820. d28 2
  821. a29 2
  822. Mkmf manages all of the directories holding Sprite system code.
  823. In normal use, all you should have to do is type "mkmf";  Mkmf
  824. d33 5
  825. a37 5
  826. Pmake to recompile in the directory, install, and so on.  The files
  827. produced by Mkmf will only work with Pmake, not with the original
  828. UNIX version of Make (but in Sprite "make" is a symbolic link to
  829. "pmake").  This man page assumes that you are familiar with Pmake;  if
  830. not, you should read the Pmake tutorial.
  831. d39 1
  832. a39 1
  833. Warning:  there is also a UNIX program called Mkmf;  although its
  834. d42 2
  835. a43 2
  836. Normally, you should re-run Mkmf in a directory whenever you add or delete
  837. source files.  When Mkmf runs, it assumes that
  838. d48 1
  839. a48 1
  840. put them in a subdirectory where Mkmf won't see them.
  841. d52 1
  842. a52 1
  843. The makefile structure that Mkmf generates is a bit complicated,
  844. d58 1
  845. a58 1
  846. there are five kinds of Pmake-related files:
  847. d60 2
  848. a61 2
  849. This is the main file generated by Mkmf, but it is short and
  850. does relatively little.  It sets up several Pmake
  851. d65 1
  852. a65 1
  853. which contain most of the useful Pmake-related information.
  854. d82 1
  855. a82 1
  856. file \fBmd.mk\fR, generated automatically by Mkmf.
  857. d93 4
  858. a96 4
  859. Pmake will do the appropriate recompilations when headers change.
  860. \fBDependencies.mk\fR files are generated automatically by Makedepend.
  861. The command ``pmake depend'' will run Makedepend
  862. to regenerate \fBdependencies.mk\fR.  Mkmf also issues
  863. d102 1
  864. a102 1
  865. of directories, there is one file of Pmake commands that contains
  866. d106 1
  867. a106 1
  868. include the sysmakefile whenever Pmake is invoked (see
  869. d118 2
  870. a119 2
  871. Several standard Pmake targets are available in any directory managed
  872. by Mkmf:
  873. d128 1
  874. a128 1
  875. Remove any files that can be regenerated automatically by Pmake.
  876. d130 1
  877. a130 1
  878. next time Pmake is invoked.
  879. d158 1
  880. a158 1
  881. header directory.  Mkmf decides
  882. d181 1
  883. a181 1
  884. Run Mkmf to regenerate the Makefile for this directory.   This target is
  885. d183 1
  886. a183 1
  887. since it will run Mkmf recursively in
  888. d190 1
  889. a190 1
  890. subdirectory and re-running Mkmf.
  891. d206 1
  892. a206 1
  893. value of the \fBTM\fR variable on the Pmake command line, such as
  894. d215 1
  895. a215 1
  896. as part of Pmake targets:
  897. d218 1
  898. a218 1
  899. If you specify a target machine as a Pmake target, such as
  900. d238 1
  901. a238 1
  902. of \fB.md\fR subdirectories at the time Mkmf is run.  To add a new target
  903. d240 1
  904. a240 1
  905. and then re-run Mkmf.
  906. d244 1
  907. a244 1
  908. There are a few variable names that Mkmf reserves exclusively
  909. d246 2
  910. a247 2
  911. generated by Mkmf will use these variables, if you set them on a
  912. Pmake command line:
  913. d267 1
  914. a267 1
  915. The makefiles generated by Mkmf won't always do the right thing
  916. d280 1
  917. a280 1
  918. Usually \fBlocal.mk\fR contains a few Pmake commands, then it
  919. d282 1
  920. a282 1
  921. SYSMAKEFILE), then it issues a few more Pmake
  922. d286 3
  923. a288 3
  924. If \fBMakefile.sed\fR exists when Mkmf runs, then Mkmf uses it as a Sed
  925. script to modify \fBMakefile\fR.  If the \fB-f\fR switch has been used
  926. to specify a different makefile, say \fBfoo\fR, then Mkmf looks for
  927. d297 1
  928. a297 1
  929. Similar to \fBMakefile.sed\fR, except Mkmf uses it as an Ex script to
  930. d301 1
  931. a301 1
  932. If this file exists when Mkmf runs, then Mkmf uses it as a
  933. d303 1
  934. a303 1
  935. of one from the Mkmf library.  See ``HOW MKMF WORKS''
  936. d308 1
  937. a308 1
  938. by Mkmf in place of the standard type-specific Mkmf script that would
  939. d316 1
  940. a316 1
  941. contains a line ``# No mkmf''.  Mkmf will refuse to do anything
  942. d322 1
  943. a322 1
  944. it is common practice to run Mkmf indiscriminately on system directories,
  945. d324 1
  946. a324 1
  947. get overwritten (actually, Mkmf won't overwrite a makefile unless
  948. d330 3
  949. a332 3
  950. The Mkmf program runs as a two-stage shell script.  The top-level
  951. script is the Mkmf program itself.  It does things that are
  952. common to all uses of Mkmf, such as checking for the ``# Allow mkmf''
  953. d339 1
  954. a339 1
  955. each type, there is an Mkmf script to generate its \fBMakefile\fR, a
  956. d347 1
  957. a347 1
  958. Mkmf uses the file \fB/sprite/lib/mkmf/mkmf.map\fR to select
  959. d353 2
  960. a354 2
  961. If Mkmf finds a script \fBmkmf.local\fR in the current directory, then
  962. Mkmf uses it instead of the one that would have been selected by
  963. d359 2
  964. a360 2
  965. You can reconfigure the way that Mkmf works by placing a file \fB.mkmf\fR
  966. in your home directory.  If this file exists, Mkmf will source it as a
  967. d363 2
  968. a364 2
  969. features of Mkmf.  For more details on how this works, read the top-level
  970. Mkmf script.
  971. d376 1
  972. a376 1
  973. subdirectories.  It is the default type used by Mkmf for directories
  974. d383 1
  975. a383 1
  976. directory (see the Mkmf scripts for details on where this is).
  977. d447 1
  978. a447 1
  979. for the standard library.  The only thing you can do with Pmake is to
  980. d457 1
  981. a457 1
  982. that do contain interesting things.  When Pmake is run in such
  983. d489 1
  984. a489 1
  985. The base directory in which a program gets installed.  Mkmf will add
  986. d495 1
  987. a495 1
  988. to add extra flags, like \fB-m 4755\fR to make a program set-user-id.
  989. d532 1
  990. a532 1
  991. a template.  Since the file may not have existed when Mkmf was run, it
  992. d534 1
  993. a534 1
  994. Mkmf.  In addition, when this program is installed (using the \fBupdate\fR
  995. d549 1
  996. a549 1
  997. default that will be made if Pmake is invoked with no arguments.  If,
  998. @
  999.  
  1000.  
  1001. 1.1
  1002. log
  1003. @Initial revision
  1004. @
  1005. text
  1006. @d1 3
  1007. a3 2
  1008. ' $Header: /sprite/doc/ref/cmds/RCS/mkmf,v 1.8 88/12/04 14:51:56 ouster Exp $ SPRITE (Berkeley)
  1009. .TH mkmf prog
  1010. d5 1
  1011. a5 1
  1012. .NA
  1013. d7 1
  1014. a7 1
  1015. .SY
  1016. @
  1017.